package com.ultimatech.webappdemo.base.model;

import com.ultimatech.webappdemo.base.GroupState;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * Created by zhangleping on 2017/5/10.
 */
@Entity
@Table(name = "sys_group")
public class SysGroup {
    private Integer id;
    private String name;
    private String moduleName;
    private String appid;
    private String appSecret;
    private String descript;
    private Date createTime;
    private Date updateTime;
    private Date expired;
    private GroupState state;
    private List<SysUser> users = new ArrayList<SysUser>();

    private List<GongzhongHao> gongzhongHaos=new ArrayList<GongzhongHao>();

    @Id
    @GeneratedValue(strategy = IDENTITY)
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Column(nullable = false, unique = true)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(nullable = false)
    public String getAppid() {
        return appid;
    }

    public void setAppid(String appid) {
        this.appid = appid;
    }

    @Column(nullable = false)
    public String getAppSecret() {
        return appSecret;
    }

    public void setAppSecret(String appSecret) {
        this.appSecret = appSecret;
    }

    @Column(nullable = false)
    public String getDescript() {
        return descript;
    }

    public void setDescript(String descript) {
        this.descript = descript;
    }

    @OneToMany(mappedBy = "group", fetch = FetchType.LAZY)
    public List<SysUser> getUsers() {
        return users;
    }

    public void setUsers(List<SysUser> users) {
        this.users = users;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    @Enumerated(EnumType.ORDINAL)
    public GroupState getState() {
        return state;
    }

    public void setState(GroupState state) {
        this.state = state;
    }

    public Date getExpired() {
        return expired;
    }

    public void setExpired(Date expired) {
        this.expired = expired;
    }

    public String getModuleName() {
        return moduleName;
    }

    public void setModuleName(String moduleName) {
        this.moduleName = moduleName;
    }

    @OneToMany(mappedBy = "group", fetch = FetchType.LAZY)
    public List<GongzhongHao> getGongzhongHaos() {
        return gongzhongHaos;
    }

    public void setGongzhongHaos(List<GongzhongHao> gongzhongHaos) {
        this.gongzhongHaos = gongzhongHaos;
    }
}
